home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / network / exp16116.zip / DEFS.ASM < prev    next >
Assembly Source File  |  1993-11-13  |  6KB  |  202 lines

  1. majver        equ    11        ;version number of the infrastructure.
  2.  
  3. MAX_ADDR_LEN    equ    16        ;maximum number of bytes in our address.
  4.  
  5. MAX_HANDLE    equ    10        ;maximum number of handles.
  6.  
  7. MAX_P_LEN    equ    8        ;maximum type length
  8.  
  9. MAX_MULTICAST    equ    8        ;maximum number of multicast addresses.
  10.  
  11. ;  Copyright, 1988-1992, Russell Nelson, Crynwr Software
  12.  
  13. ;   This program is free software; you can redistribute it and/or modify
  14. ;   it under the terms of the GNU General Public License as published by
  15. ;   the Free Software Foundation, version 1.
  16. ;
  17. ;   This program is distributed in the hope that it will be useful,
  18. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. ;   GNU General Public License for more details.
  21. ;
  22. ;   You should have received a copy of the GNU General Public License
  23. ;   along with this program; if not, write to the Free Software
  24. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  
  26. HT    equ    09h
  27. CR    equ    0dh
  28. LF    equ    0ah
  29.  
  30. ;
  31. ;  Packet Driver Error numbers
  32. NO_ERROR    equ    0        ;no error at all.
  33.   ifndef SMCINC
  34. BAD_HANDLE    equ    1        ;invalid handle number
  35.   endif
  36. NO_CLASS    equ    2        ;no interfaces of specified class found
  37. NO_TYPE        equ    3        ;no interfaces of specified type found
  38. NO_NUMBER    equ    4        ;no interfaces of specified number found
  39.   ifndef SMCINC
  40. BAD_TYPE    equ    5        ;bad packet type specified
  41.   endif
  42. NO_MULTICAST    equ    6        ;this interface does not support
  43.                     ;multicast
  44. CANT_TERMINATE    equ    7        ;this packet driver cannot terminate
  45. BAD_MODE    equ    8        ;an invalid receiver mode was specified
  46. NO_SPACE    equ    9        ;operation failed because of
  47.                     ;insufficient space
  48. TYPE_INUSE    equ    10        ;the type had previously been accessed,
  49.                     ;and not released.
  50. BAD_COMMAND    equ    11        ;the command was out of range, or not
  51.                     ;implemented
  52. CANT_SEND    equ    12        ;the packet couldn't be sent (usually
  53.                     ;hardware error)
  54. CANT_SET    equ    13        ;hardware address couldn't be changed
  55.                     ;(more than 1 handle open)
  56. BAD_ADDRESS    equ    14        ;hardware address has bad length or
  57.                     ;format
  58. CANT_RESET    equ    15        ;Couldn't reset interface (more than
  59.                     ;1 handle open).
  60. BAD_IOCB    equ    16        ;an invalid iocb was specified
  61.  
  62. ;a few useful Ethernet definitions.
  63. RUNT        equ    60        ;smallest legal size packet, no fcs
  64. GIANT        equ    1514        ;largest legal size packet, no fcs
  65. EADDR_LEN    equ    6        ;Ethernet address length.
  66. ARCADDR_LEN    equ    1
  67.  
  68. BLUEBOOK    equ    1
  69. IEEE8023    equ    11
  70.  
  71. ;The following two macros are used to manipulate port addresses.
  72. ;Use loadport to initialize dx.  Use setport to set a specific port on
  73. ;the board.  setport remembers what the current port number is, but beware!
  74. ;setport assumes that code is being executed in the same order as the
  75. ;code is presented in the source file.  Whenever this assumption is violated,
  76. ;you need to enter another loadport.  Some, but not all examples are:
  77. ;in a loop with multiple setports, or a backward jump over a setport, or
  78. ;a forward jump over a setport.  If you have any doubt, consult the
  79. ;individual driver sources for examples of usage.  If you suspect that
  80. ;you have too few loadports, define the symbol "no_confidence" to a
  81. ;one.  This will force a loadport before every setport.  If you wish to turn
  82. ;it off for some of your code, redefine it to a zero.
  83.  
  84. loadport    macro
  85.     mov    dx,io_addr
  86. port_no    =    0
  87.     endm
  88.  
  89. ;change the port number from the current value to the new value.
  90. setport    macro    new_port_no
  91.     ifdef    no_confidence        ;define if you suspect that you don't
  92.       if    no_confidence
  93.         loadport        ;  have enough loadports, i.e. dx is
  94.       endif
  95.     endif                ;  set to the wrong port.
  96.     if    new_port_no - port_no EQ 1
  97.         inc    dx
  98.     else
  99.         if    new_port_no - port_no EQ -1
  100.             dec    dx
  101.         else
  102.             if    new_port_no - port_no NE 0
  103.                 add    dx,new_port_no - port_no
  104.             endif
  105.         endif
  106.     endif
  107. port_no    =    new_port_no
  108.     endm
  109.  
  110. ;this macro does a "rep movsb" with a static count.
  111. repmov    macro    count
  112.     rept    (count) / 2
  113.     movsw
  114.     endm
  115.     rept    (count) MOD 2
  116.     movsb
  117.     endm
  118.     endm
  119.  
  120. ;moves a segment register into another segment register.
  121. movseg    macro    to, from
  122.     push    from
  123.     pop    to
  124.     endm
  125.  
  126. ;add a word to a dword.
  127. add2    macro    n,a            ; inc a 32 bit integer
  128.     add    n.offs,a        ;increment the low word
  129.     adc    n.segm,0        ;increment the high word
  130.     endm
  131.  
  132. ;this macro writes the given character to the given row and column on
  133. ;  an CGA.
  134. to_scrn    macro    r, c, ch
  135.     local    again
  136.     push    bx
  137.     push    es
  138.     mov    bx,0b800h
  139.     mov    es,bx
  140.     mov    bx,es:[r*160+c*2]
  141. again:
  142.     inc    bh
  143.     and    bh,07h
  144.     je    again            ;; don't use black.
  145.     mov    bl,ch
  146.     mov    es:[r*160+c*2],bx
  147.     pop    es
  148.     pop    bx
  149.     endm
  150.  
  151.  
  152.  
  153. segmoffs    struc            ; defines offs as 0, segm as 2
  154. offs        dw    ?
  155. segm        dw    ?
  156. segmoffs    ends
  157.  
  158. CY    equ    0001h
  159. EI    equ    0200h
  160.  
  161. iocb        struc            ; as_send_pkt structure
  162. buffer        dd    ?        ; Pointer to the buffer
  163. len        dw    ?        ; Its length
  164. flags        db    ?        ; Some flags
  165. ret_code    db    ?        ; Completion code
  166. upcall        dd    ?        ; I/O completion upcall
  167. next        dd    ?        ; Private next pointer (queue)
  168. resv        db    4 dup (?)    ; Unused private data
  169. iocb        ends
  170.  
  171. DONE    equ    1        ; I/O complete flag
  172. CALLME    equ    2        ; Please upcall me flag
  173.  
  174.  
  175. send_queueempty    macro
  176. ; Check if send queue is empty.
  177. ; Enter with interrupts disabled.
  178. ; Exit with zr (zero) if empty, nz (not zero) if not.
  179. ; Destroys ax.
  180.     mov ax,    word ptr send_head    ; Queue empty?
  181.     or ax,    word ptr send_head+2
  182.     endm
  183.  
  184. send_peekqueue    macro
  185. ; Peek into the queue and get the next entry.
  186. ; Enter with interrupts disabled.
  187. ; Exit with es:di -> iocb.
  188.     les di, send_head    ; Get head segment:offset
  189.     endm
  190.  
  191. ; Bits in sys_features
  192. SYS_MCA    equ    02        ; a micro channel computer
  193. TWO_8259    equ    40h        ; 2nd 8259 exists
  194.  
  195. ; Bits in flagbyte
  196. CALLED_ETOPEN    equ    1        ; have called etopen
  197. D_OPTION    equ    2        ; delayed initialization
  198. N_OPTION    equ    4        ; Novell protocol conversion
  199. W_OPTION    equ    8        ; Windows upcall checking.
  200. U_OPTION    equ    10h        ; Terminate the driver.
  201.  
  202.